package com.example.demo.controller;

import com.example.demo.annotation.TestAnnotation;
import com.example.demo.controller.vo.TestCReq;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author kaka
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/testA")
    public String testA(@RequestParam(value = "aa", required = false) String aa) {

        log.info("testA请求成功:aa={}", aa);

        return "testA请求成功:aa=" + aa;
    }

    @TestAnnotation(value = "testB")
    @GetMapping("/testB")
    public String testB(@RequestParam(value = "aa", required = false) String aa) {

        log.info("testB请求成功:aa={}", aa);

        return "testB请求成功:aa=" + aa;
    }

    @TestAnnotation(value = "testC")
    @PostMapping("/testC")
    public String testC(@Valid @RequestBody TestCReq req) {

        log.info("testC请求成功:aa={}", req);

        return "testC请求成功:aa=" + req;
    }

    @TestAnnotation(value = "testD")
    @GetMapping("/testD")
    public String testD(@RequestParam("aa") @NotBlank String aa) {

        log.info("testD请求成功:aa={}", aa);

        return "testD请求成功:aa=" + aa;
    }
}
